<?php
namespace app\index\controller;
use think\Request;
use think\Db;
/**
* 
*/
class Weather extends \think\Controller
{
	
	public function getClimateInfo(){
		$request = Request::instance();
        if($request->isPost()){
        	$data = $request->except(['name']);
        	$city = trim($data['city']) == '' ? '阳原' : trim($data['city']);
        }
        //var_dump($city);
       	$url='http://wthrcdn.etouch.cn/weather_mini?city='.$city;
        // var_dump($url);
       	$ch = curl_init();
          $timeout = 5;
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch,CURLOPT_ENCODING ,'gzip');
          curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
          $file_contents = curl_exec($ch);
          curl_close($ch);
         
          $result = Db::table('eqtinformationnew')->field('climate')->where('eqtname', '=', $city)->select();
          $clidescription = $result[0];
          $clidata=json_decode($file_contents);
          $data = [
            'clidescription' => $clidescription,
            'clidata' =>  $clidata
          ];
          $data = json_encode($data);
          //var_dump($data);
          return $data;
         
      
      //  $url = 'http://wthrcdn.etouch.cn/weather_mini?city=北京';
      //   $html = file_get_contents($url);
      // // echo urldecode($html);
      //   echo gzdecode($html);
     
		 
     }
}
?>